package cn.appsys.service.developer;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.appsys.dao.appinfo.AppInfoMapper;
import cn.appsys.pojo.AppInfo;

@Service
public class AppInfoServiceImpl implements AppInfoService {

	@Resource
	private AppInfoMapper appInfoMapper;

	@Override
	public List<AppInfo> getAppInfoList(String _querySoftwareName, String _queryStatus, String flatformId,
			String _queryCategoryLevel1, String _queryCategoryLevel2, String _queryCategoryLevel3, Integer pageSize,
			Integer currentPageNo, Integer devId) {
		List<AppInfo> list = null;
		list = appInfoMapper.getAppInfoList(_querySoftwareName, _queryStatus, flatformId, _queryCategoryLevel1,
				_queryCategoryLevel2, _queryCategoryLevel3, pageSize, (currentPageNo - 1) * pageSize, devId);
		return list;
	}

	@Override
	public int getAppInfoCount(String _querySoftwareName, String _queryStatus, String flatformId,
			String _queryCategoryLevel1, String _queryCategoryLevel2, String _queryCategoryLevel3, Integer devId) {
		return appInfoMapper.getAppInfoCount(_querySoftwareName, _queryStatus, flatformId, _queryCategoryLevel1,
				_queryCategoryLevel2, _queryCategoryLevel3, devId);
	}

	@Override
	public int apkExist(String APKName) {
		return appInfoMapper.apkExist(APKName);
	}

	@Override
	public boolean addAppInfo(AppInfo appInfo) {
		boolean b = false;
		if (appInfoMapper.addAppInfo(appInfo) > 0) {
			b = true;
		}
		return b;
	}

	@Override
	public AppInfo getAppInfo(Integer id) {
		return appInfoMapper.getAppInfo(id);
	}

	@Override
	public boolean delFile(Integer id) {
		boolean b = false;
		if (appInfoMapper.delFile(id) > 0) {
			b = true;
		}
		return b;
	}

	@Override
	public boolean modifyAppInfo(AppInfo appInfo) {
		boolean b = false;
		if (appInfoMapper.modifyAppInfo(appInfo) > 0) {
			b = true;
		}
		return b;
	}

	@Override
	public boolean updateAppInfoVersion(Integer id, Integer versionId) {
		boolean flag = false;
		if (appInfoMapper.updateAppInfoVersion(id, versionId) > 0) {
			flag = true;
		}
		return flag;
	}

	@Override
	public boolean delApp(String id) {
		boolean flag = false;
		if (appInfoMapper.delApp(id) > 0) {
			flag = true;
		}
		return flag;
	}

	@Override
	public boolean updateAppStatus(Integer status, Integer id) {
		boolean flag = false;
		if (appInfoMapper.updateAppStatus(status, id) > 0) {
			flag = true;
		}
		return flag;
	}
}
